//
//  Arguments.swift
//  red_house
//
//  Created by gix on 2024/5/10.
//

import Foundation
import CoreBluetooth
import Flutter

struct ScanArguments {
    
    let services: [CBUUID]?
    let allowDuplicationKey: Bool
    let events: FlutterEventSink
    
    static func from(_ arguments: Any?, events: @escaping FlutterEventSink) -> ScanArguments {
        if let args = arguments as? [String: Any] {
            return ScanArguments(services: (args["services"] as? [String])?.map{ CBUUID(string: $0) }, allowDuplicationKey: args["allowDuplicationKeys"] as? Bool ?? false, events: events)
        }
        return ScanArguments(services: nil, allowDuplicationKey: false, events: events)
    }
}
